//copyit.cpp -- copy() and iterator
#include<iostream>
#include<vector>
#include<string>
#include<iterator>

int main()
{
	using namespace std;
	int casts[10]={6,7,2,9,4,11,8,7,10,5};
	vector<int> dice(10);
	
	//copy from array to vector
	copy(casts,casts+10,dice.begin());//复制范围，复制到
	cout<<"let the dice be cast!\n";

	//create an ostream iterator
	ostream_iterator<int,char> out_iter(cout," ");//将int作为char输出
	
	//copy from vector to output
	copy(dice.begin(),dice.end(),out_iter);
	cout<<endl;//just endl;

	cout<<"implicit use of reverse iterator.\n";
	
	copy(dice.begin(),dice.end(),out_iter);
	cout<<endl;//just endl;
	cout<<"Explicit use of reverse iterator.\n";
	vector<int>::reverse_iterator ri;
	
	for(ri=dice.rbegin();ri!=dice.rend();++ri)
		cout<<*ri<<' ';//gdb test ,nothing cout here
	cout<<endl;//just endl;
	return 0;
}

